// ex6_8.cpp
#include <iostream>
#include <fstream>

int main(void)
{
    using namespace std;
    ifstream inFile; 
    inFile.open("test123.txt",ios::in);
    if (!inFile.is_open())
    {
        cout << "file open failed!" << endl;
        exit(EXIT_FAILURE);
    }
    char ch;
    long count = 0L; 
    while (!inFile.eof())
    {
        inFile.get(ch);
        if (ch != '\n') 
            ++count;
    }
    if (inFile.eof())
        cout << "End of file reached\n";
    inFile.close();
    cout << "Total of file is: " << count << " characters." << endl;
    return 0;
}
